package Cy.Servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Cy.DAO.CommodityTypeDAO;
import Entity.CommodityType;
import Factory.CommodityTypeFactory;

/**
 * Servlet implementation class UpdateCommodityTypeServlet
 */
@WebServlet("/updatecommoditytype")
public class UpdateCommodityTypeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private CommodityTypeDAO commoditytype = CommodityTypeFactory.createDAO();
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		int ctId = Integer.parseInt(request.getParameter("ctId"));
		String ctName = request.getParameter("ctName");
		String erorr = commoditytype.updatecommoditytype(ctId, ctName);
		request.setAttribute("erorr", erorr);
		request.setAttribute("ctId", ctId);
		request.getRequestDispatcher("updateCommodityType.jsp").forward(request, response);
	}

}
